<template>
  <div class="sub-form-action-config">
    <div>[{{subFormName}}]:</div>
    <table>
      <tr>
        <td>新建</td>
        <td>复制</td>
        <td>删除行</td>
        <td>删除全部</td>
        <td>上移</td>
        <td>下移</td>
      </tr>
      <tr>
        <td><a-checkbox :checked="subFormAuth.addRow" @click="() => subFormAuth.addRow = !subFormAuth.addRow"/></td>
        <td><a-checkbox :checked="subFormAuth.copyRow" @click="() => subFormAuth.copyRow = !subFormAuth.copyRow"/></td>
        <td><a-checkbox :checked="subFormAuth.removeRow" @click="() => subFormAuth.removeRow = !subFormAuth.removeRow"/></td>
        <td><a-checkbox :checked="subFormAuth.clearRow" @click="() => subFormAuth.clearRow = !subFormAuth.clearRow"/></td>
        <td><a-checkbox :checked="subFormAuth.moveUp" @click="() => subFormAuth.moveUp = !subFormAuth.moveUp"/></td>
        <td><a-checkbox :checked="subFormAuth.moveDown" @click="() => subFormAuth.moveDown = !subFormAuth.moveDown"/></td>
      </tr>
    </table>
  </div>
</template>
<script>
import { createProps } from '@/utils'
import { createSubFormAuthFormula } from '@comp/hhd/design/FormDesigner/types'

export default {
  name: 'SubFormActionConfig',
  props: {
    subFormAuth: createProps(Object, createSubFormAuthFormula),
    formDefinition: createProps(Object, () => undefined),
    subFormAction: createProps(Object, () => undefined)
  },
  computed: {
    subFormName() {
      if (!this.formDefinition || !this.subFormAction) return undefined
      let subForm = (this.formDefinition.subForms || []).find(s => s.id === this.subFormAction.subFormId)
      return subForm && subForm.formName || undefined
    }
  }
}
</script>
<style>
.sub-form-action-config {
  padding-left: 10px;
  padding-top: 10px;
}

.sub-form-action-config table  td {
  padding-right: 10px;
}
</style>